package com.lkm.app_ui.jz.util;

import android.widget.Toast;

import com.lkm.app_ui.MyApplication;

public class Print {
    private static String TAG    = "Bill->";
    private static int    Lenght = 1800;

    public static void d(String msg) {
        d(msg, TAG);
    }

    public static void d(String msg, String tag) {
        if (!MyApplication.getInstance().isDebug()) return;
        String message = "";
        String tag_    = TAG;
        if (msg != null) message = msg;
        if (tag == null) tag_ = TAG;
        if (message.length() > Lenght) {
            System.out.println(tag_ + message.substring(0, Lenght));
            if ((message.length() - Lenght) > Lenght) { //剩下的文本还是大于规定长度
                System.out.println(message.substring(Lenght, message.length()));
            } else {
                System.out.println(tag_ + message.substring(Lenght));
            }
        } else {
            System.out.println(tag_ + message);
        }
    }

    private static Toast toast;

    public static void showToast(String msg) {
        showToast(msg, Toast.LENGTH_SHORT);
    }

    public static void showToast(String msg, int duration) {
        String msg_ = "";
        if (msg != null) msg_ = msg;
        if (toast == null) toast = Toast.makeText(MyApplication.getInstance(), msg_, duration);
        else toast.setText(msg);
        toast.show();
    }
}
